<template>
  <div class="select-none">
    <img :src="bg" class="wave" alt="">
    <div class="flex-c absolute right-5 top-3"></div>
    <div class="login-container">
      <div class="img">
           <img :src="dog"  alt=""/>
      </div>
      <div class="login-box">
        <div class="login-form">
          <div class="login-title">YANG-UI</div>
          <el-tabs v-model="tabsActiveName">
            <!-- 用户名密码登录 -->
            <el-tab-pane label="用户名登录" name="account">
              <Password @signInSuccess="signInSuccess" />
            </el-tab-pane>
            <!-- 手机号登录 -->
            <el-tab-pane label="手机号登录" name="mobile">
              <Mobile @signInSuccess="signInSuccess" />
            </el-tab-pane>
            <!-- 注册 -->
            <el-tab-pane label="注册" name="register" v-if="registerEnable">
              <Register @afterSuccess="tabsActiveName = 'account'" />
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </div>
  </div>

</template>

<script setup>
// icon-yincangmima 使用到了ali的字体
import "/@/assets/login/ali.css";
import bg from '/@/assets/login/bg.png';
import dog from '/@/assets/login/cute-dog.jpeg';
import {defineAsyncComponent, ref} from "vue";
import {useMessage} from "/@/hooks/message.js";
import {Session} from "/@/utils/storage.js";
// import { initBackEndControlRoutes } from '/@/router/backEnd';

// 引入组件
const Password = defineAsyncComponent(() => import('./component/password.vue'));
const Mobile = defineAsyncComponent(() => import('./component/mobile.vue'));
const Register = defineAsyncComponent(() => import('./component/register.vue'));

// 默认选择账号密码登录方式
const tabsActiveName = ref('account');

// 是否开启注册
const registerEnable = ref(import.meta.env.VITE_REGISTER_ENABLE === 'true');


// 登录成功后的跳转处理事件
const signInSuccess = async () => {
  // const isNoPower = await initBackEndControlRoutes();
  const isNoPower =false;
  if (isNoPower) {
    useMessage.warning('抱歉，您没有登录权限');
    Session.clear();
  } else {
    // 初始化登录成功时间问候语
    // let currentTimeInfo = formatAxis(new Date());
    // if (route.query?.redirect) {
    //   router.push({
    //     path: <string>route.query?.redirect,
    //       query: Object.keys(<string>route.query?.params).length > 0 ? JSON.parse(<string>route.query?.params) : '',
    //         });
    //         } else {
    //           router.push('/');
    //         }
    //         // 登录成功提示
    //         const signInText = t('signInText');
    //         useMessage().success(`${currentTimeInfo}，${signInText}`);
    //         // 添加 loading，防止第一次进入界面时出现短暂空白
    //         NextLoading.start();
            }
            };

</script>

<style scoped lang="scss">
//@import "@/@/";
//@import "./assets/css/part.scss";
</style>